package com.example.text.controller;

import com.example.text.common.result.Result;
import com.example.text.common.result.ResultFactory;
import com.example.text.entity.AdminMenu;
import com.example.text.service.AdminMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class MenuController {

    @Autowired
    AdminMenuService adminMenuService;

    @CrossOrigin
    @GetMapping("/api/menu")
    public Result menu() {
          List<AdminMenu> menus=adminMenuService.getMenusByCurrentUser();
          System.out.println(menus);
        return ResultFactory.buildSuccessResult(menus);
    }
    @CrossOrigin
    @GetMapping("/api/admin/role/menu")
    public Result listAllMenus() {
        return ResultFactory.buildSuccessResult(adminMenuService.getMenusByRoleId(1));
    }
}
